package com.twu.biblioteca;

import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;

public class UserAccount {
    private Map<String, String> loginDetails;
    private Map<String, String> personalDetails;
    private PrintStream stream;

    public UserAccount(PrintStream stream) {
        this.stream = stream;
        loginDetails = new HashMap<String, String>();
        personalDetails = new HashMap<String, String>();

        loginDetails.put("111-1111", "you");
        loginDetails.put("111-1112", "me");

        personalDetails.put("111-1111", "katlego " + " k@gmail.com " + " 090 888 9080");
        personalDetails.put("111-1112", "sphiwe " + " s@gmail.com" + " 023 989 7890");
    }

    public boolean checkLoginDetails(String userName, String password) {
        if (!loginDetails.containsKey(userName) && !loginDetails.containsValue(password)) {
            throw new IllegalArgumentException("Your username/password is not correct");
        }
        return loginDetails.containsKey(userName) && loginDetails.containsValue(password);
    }

    public void checkMembership(String userName) {
        if (!userName.equals(null)) {
            stream.println(personalDetails.get(userName));
        }
    }
}
